﻿using MvcApplication1.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Mvcapplication1.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            var laListaDePersonas = PersonaContenedor.personas;
            return View(model: laListaDePersonas);
        }

        [HttpGet]
        public ActionResult Agregar()
        {
            return View();
        }
        [HttpGet]
        public ActionResult Borrar()
        {
            return View();
        }
        [HttpGet]
        public ActionResult Editar()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Agregar(Persona unaPersona)
        {
           PersonaContenedor.agregarPersona(unaPersona);
            return RedirectToAction("Index");
        }
        [HttpPost]
        public ActionResult Borrar(Persona unaPersona)
        {
            PersonaContenedor.quitarPersona(unaPersona);
            return RedirectToAction("Index");
        }
        [HttpPost]
        public ActionResult Editar(Persona unaPersona,Persona nuevaPersona)
        {
            PersonaContenedor.editarPersona(unaPersona,nuevaPersona);
            return RedirectToAction("Index");
        }

    }
}
